//
//  PickimageWayView.m
//  BaiLeTou
//
//  Created by toro宇 on 2017/10/17.
//  Copyright © 2017年 yijie. All rights reserved.
//

#import "PickimageWayView.h"
@interface PickimageWayView()
@property (weak, nonatomic) IBOutlet UIButton *shadowBtn;
@property (weak, nonatomic) IBOutlet UIView *bottomView;

@end

@implementation PickimageWayView

+ (PickimageWayView *)pickimageWayView:(void(^)(PickimagewayType pickimagewayType))pickimagewayTypeBlock
{
    PickimageWayView *pickimageView = [[[UINib nibWithNibName:@"PickimageWayView" bundle:nil] instantiateWithOwner:nil options:nil] firstObject];
    pickimageView.pickimageTypeBlock = pickimagewayTypeBlock;
    return pickimageView;
}

-(void)didMoveToSuperview
{
    self.frame = self.superview.bounds;
    self.shadowBtn.alpha = 0;
    self.bottomView.transform = CGAffineTransformMakeTranslation(0, self.bottomView.frame.size.height);
//    self.bottomView.transform = CGAffineTransformScale(self.bottomView.transform, 0.2, 0.2);
    [UIView animateWithDuration:0.3 animations:^{
        self.bottomView.transform = CGAffineTransformIdentity;
        self.shadowBtn.alpha = 0.3;
        self.shadowBtn.alpha = 0.4;
    } completion:^(BOOL finished) {
   
    }];
}
#pragma mark - IB

- (IBAction)selectedBtn:(UIButton *)sender
{
    if (self.pickimageTypeBlock) {
        PickimagewayType pickimagewayType;
        switch (sender.tag) {
            case 100:
                // 从相册
                pickimagewayType = PickimagewayTypeLibrary;
                break;
            case 101:
                pickimagewayType = PickimagewayTypeCamera;
                break;
            default:
                pickimagewayType = PickimagewayTypeCancle;
                break;
        }
        self.pickimageTypeBlock(pickimagewayType);
    }
    [self removeFromSuperview];
  
    
}

- (IBAction)shadowBtn:(UIButton *)sender {
    [self removeFromSuperview];
}


@end
